package org.thunms.framework.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

public abstract class ControllerDefault extends ControllerDefaultBase {
	private static final long serialVersionUID = 7248632802343834708L;

	public ControllerDefault(String platformId, String systemId, String moduleId) {
		super(platformId, systemId, moduleId);
	}
	private static final Logger logger = LoggerFactory.getLogger(ControllerDefault.class);
	
	/**
	 * 转向初始化页面.
	 * 约定格式:/platformId/systemId/moduleId/moduleId.jsp.
	 * @return
	 */
	//@Cacheable(value="thunmsControllerCache")
	@RequestMapping
	public String initPage(HttpServletRequest request, HttpServletResponse response,Model model) {
		this.initPageCallback(request, response, model);
		return this.initpage;
	}
	/**
	 * 页面初始化时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void initPageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
		
	}
	
	/**
	 * 转向新增页面.
	 * 约定格式:/platformId/systemId/moduleId/moduleId_add.jsp.
	 * @return
	 */
	@RequestMapping(value = "/add")
	public  String add(HttpServletRequest request, HttpServletResponse response,Model model) {
		this.addPageCallback(request, response, model);
		return this.getRerutnURL("add");
	}
	/**
	 * 转向新增页面时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void addPageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
	}
	
	/**
	 * 转向修改页面.
	 * 约定格式:/platformId/systemId/moduleId/moduleId_update.jsp.
	 * @return
	 */
	@RequestMapping(value = "/update")
	public  String update(HttpServletRequest request, HttpServletResponse response,Model model) {
		this.updatePageCallback(request, response, model);
		return this.getRerutnURL("update");
	}
	
	/**
	 * 转向修改页面时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void updatePageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
		
	}
	/**
	 * 转向查看页面.
	 * 约定格式:/platformId/systemId/moduleId/moduleId_look.jsp.
	 * @return
	 */
	@RequestMapping(value = "/look")
	public  String look(HttpServletRequest request, HttpServletResponse response,Model model) {
		this.lookPageCallback(request, response, model);
		return this.getRerutnURL("look");
	}
	/**
	 * 转向查看页面时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void lookPageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
		
	}
	
	/**
	 * 转向查询页面.
	 * 约定格式:/platformId/systemId/moduleId/moduleId_query.jsp.
	 * @return
	 */
	@RequestMapping(value = "/query")
	public  String query(HttpServletRequest request, HttpServletResponse response,Model model) {
		this.queryPageCallback(request, response, model);
		return this.getRerutnURL("query");
		
	}
	/**
	 * 转向查询页面时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void queryPageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
		
	}
	
	/**
	 * 数据列表页面.
	 * 约定格式:/platformId/systemId/moduleId/moduleId_list.jsp.
	 * @return
	 */
	@RequestMapping(value = "/list")
	public String list(HttpServletRequest request, HttpServletResponse response,Model model) {
		this.listPageCallback(request, response, model);
		return getRerutnURL("list");
	}
	/**
	 * 数据列表页面时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void listPageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
		
	}
	
	/**
	 * 首页portal界面展示.
	 * 约定格式:/platformId/systemId/moduleId/moduleId_portal.jsp.
	 * @return
	 */
	@RequestMapping(value = "/portal")
	public String portal(HttpServletRequest request, HttpServletResponse response,Model model) {
		this.portalPageCallback(request, response, model);
		return getRerutnURL("portal");
	}
	
	/**
	 * 首页portal界面展示时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void portalPageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
		
	}
	
	/**
	 * 用于自定义数据查询页面
	 */
	@RequestMapping(value = "/select")
	public  String select(Boolean singleSelect,HttpServletRequest request, HttpServletResponse response,Model model) {
		model.addAttribute("singleSelect", singleSelect);
		this.selectPageCallback(request, response, model);
		return this.getRerutnURL("select");
	}
	/**
	 * 用于查询页面展示时候回调方法.用于扩展默认方法的不足.
	 * @param request
	 * @param response
	 * @param model
	 */
	protected void selectPageCallback(HttpServletRequest request, HttpServletResponse response,Model model){
		
	}
	
	
}
